package com.freedom.ums.member.application.service.query;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.freedom.ums.member.application.converter.MemberConverter;
import com.freedom.ums.member.domain.repository.MemberRepository;
import com.freedom.ums.member.infrastructure.persistence.pojo.bo.MemberBO;
import com.freedom.ums.member.infrastructure.persistence.pojo.query.admin.AdminMemberPageQuery;
import com.freedom.ums.member.infrastructure.persistence.pojo.vo.admin.AdminMemberPageVO;
import com.freedom.ums.api.member.pojo.dto.MemberAuthDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class MemberQueryService {

    private final MemberRepository memberRepository;

    private final MemberConverter memberConverter;

    public Page<AdminMemberPageVO> queryMemberPage(AdminMemberPageQuery queryParam) {
        Page<MemberBO> resultPage = memberRepository.queryMemberPage(queryParam);
        return memberConverter.toPageVO(resultPage);
    }

    public MemberAuthDTO findMemberByMobile(String mobile) {
        MemberBO memberBO = memberRepository.findMemberByMobile(mobile);
        return memberConverter.toDTO(memberBO);
    }
}
